import request from '@/utils/request'

// 查询车位费列表
export function listParking(query) {
  return request({
    url: '/system/parking/list',
    method: 'get',
    params: query
  })
}

// 查询车位费详细
export function getParking(pid) {
  return request({
    url: '/system/parking/' + pid,
    method: 'get'
  })
}

// 新增车位费
export function addParking(data) {
  return request({
    url: '/system/parking',
    method: 'post',
    data: data
  })
}

// 修改车位费
export function updateParking(data) {
  return request({
    url: '/system/parking',
    method: 'put',
    data: data
  })
}

// 删除车位费
export function delParking(pid) {
  return request({
    url: '/system/parking/' + pid,
    method: 'delete'
  })
}



/**
 * 获取当前时间,为订单号提供
 * 格式YYYYMMDDHHMMSS
 */
export const getDateNums = (date) => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('') + [hour, minute, second].map(formatNumber).join('')
}
const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}
